from unittest import TestCase
from ddt import ddt, data, unpack
from selenium import webdriver
from basic.zhuce  import TestUntitled1
from basicdata.zhucedata import ZHUCEData1

# 注册用例
@ddt
class ZHUCE(TestCase):

    # 209用例：点击租户注册，输入正确的邮箱，进行注册会跳转到第二步
    @data(*ZHUCEData1().data1())
    @unpack
    def testassessment209(self, name, expect):
        # # 创建浏览器对象
        driver = webdriver.Chrome()
        # 执行登陆并新增考核表等操作
        log = TestUntitled1()
        log.test_untitled_a(driver)
        # 获取实际结果并断言
        result = log.test_untitled1(driver, name)
        if result != expect:
            driver.save_screenshot("209bug.jpg")
        driver.quit()
        self.assertEqual(expect, result)

    # 210用例：点击租户注册，输入错误邮箱/特殊字符，进行注册会提示：输入正确的邮箱
    @data(*ZHUCEData1().data2())
    @unpack
    def testassessment210(self, name, expect):
        # # 创建浏览器对象
        driver = webdriver.Chrome()
        # 执行登陆并新增考核表等操作
        log = TestUntitled1()
        log.test_untitled_a(driver)
        # 获取实际结果并断言
        result = log.test_untitled2(driver, name)
        if result != expect:
            driver.save_screenshot("210bug.jpg")
        driver.quit()
        self.assertEqual(expect, result)

    # 214用例：点击租户注册，输入已经注册过的的邮箱，会提示：您的邮箱已注册成宏景云用户/服务商，可以用邮箱作为账号登录！
    @data(*ZHUCEData1().data3())
    @unpack
    def testassessment214(self, name, expect):
        # # 创建浏览器对象
        driver = webdriver.Chrome()
        # 执行登陆并新增考核表等操作
        log = TestUntitled1()
        log.test_untitled_a(driver)
        # 获取实际结果并断言
        result = log.test_untitled3(driver, name)
        if result != expect:
            driver.save_screenshot("214bug.jpg")
        driver.quit()
        self.assertEqual(expect, result)

    # 219用例：点击租户注册时，不输入邮箱，点击注册时会提示：请输入邮箱
    @data(*ZHUCEData1().data4())
    @unpack
    def testassessment219(self,  expect):
        # # 创建浏览器对象
        driver = webdriver.Chrome()
        # 执行登陆并新增考核表等操作
        log = TestUntitled1()
        log.test_untitled_a(driver)
        # 获取实际结果并断言
        result = log.test_untitled4(driver)
        if result != expect:
            driver.save_screenshot("219bug.jpg")
        driver.quit()
        self.assertEqual(expect, result)

# 211用例：点击服务商注册，输入正确的邮箱，进行注册会跳转到第二步
    @data(*ZHUCEData1().data5())
    @unpack
    def testassessment211(self, name, expect):
        # # 创建浏览器对象
        driver = webdriver.Chrome()
        # 执行登陆并新增考核表等操作
        log = TestUntitled1()
        log.test_untitled_b(driver)
        # 获取实际结果并断言
        result = log.test_untitled1(driver, name)
        if result != expect:
            driver.save_screenshot("211bug.jpg")
        driver.quit()
        self.assertEqual(expect, result)

# 212用例：点击服务商注册，输入错误邮箱/特殊字符，进行注册会提示：输入正确的邮箱
    @data(*ZHUCEData1().data6())
    @unpack
    def testassessment212(self, name, expect):
        # # 创建浏览器对象
        driver = webdriver.Chrome()
        # 执行登陆并新增考核表等操作
        log = TestUntitled1()
        log.test_untitled_b(driver)
        # 获取实际结果并断言
        result = log.test_untitled2(driver, name)
        if result != expect:
            driver.save_screenshot("212bug.jpg")
        driver.quit()
        self.assertEqual(expect, result)

# 213用例：点击服务商注册，输入已经注册过的的邮箱，会提示：您的邮箱已注册成宏景云用户/服务商，可以用邮箱作为账号登录！
    @data(*ZHUCEData1().data7())
    @unpack
    def testassessment213(self, name, expect):
        # # 创建浏览器对象
        driver = webdriver.Chrome()
        # 执行登陆并新增考核表等操作
        log = TestUntitled1()
        log.test_untitled_b(driver)
        # 获取实际结果并断言
        result = log.test_untitled3(driver, name)
        if result != expect:
            driver.save_screenshot("213bug.jpg")
        driver.quit()
        self.assertEqual(expect, result)

# 215用例：点击服务商注册，输入未激活的的邮箱，会提示： 您的邮箱尚未激活成为宏景云用户，点击注册重新获取链接！
    @data(*ZHUCEData1().data8())
    @unpack
    def testassessment215(self, name, expect):
        # # 创建浏览器对象
        driver = webdriver.Chrome()
        # 执行登陆并新增考核表等操作
        log = TestUntitled1()
        log.test_untitled_b(driver)
        # 获取实际结果并断言
        result = log.test_untitled3(driver, name)
        if result != expect:
            driver.save_screenshot("215bug.jpg")
        driver.quit()
        self.assertEqual(expect, result)

#220用例：点击服务商注册时，邮箱输入框为空时，点击注册会提示：请输入邮箱
    @data(*ZHUCEData1().data9())
    @unpack
    def testassessment220(self,  expect):
        # # 创建浏览器对象
        driver = webdriver.Chrome()
        # 执行登陆并新增考核表等操作
        log = TestUntitled1()
        log.test_untitled_b(driver)
        # 获取实际结果并断言
        result = log.test_untitled4(driver)
        if result != expect:
            driver.save_screenshot("220bug.jpg")
        driver.quit()
        self.assertEqual(expect, result)

#217用例：点击个人注册，输入特殊字符的单位注册码，进行注册会提示：请输入字母或数字
    @data(*ZHUCEData1().data10())
    @unpack
    def testassessment217(self, name,expect):
        # # 创建浏览器对象
        driver = webdriver.Chrome()
        # 执行登陆并新增考核表等操作
        log = TestUntitled1()
        log.test_untitled_c(driver)
        # 获取实际结果并断言
        result = log.test_untitled5(driver, name)
        if result != expect:
            driver.save_screenshot("217bug.jpg")
        driver.quit()
        self.assertEqual(expect, result)

#218用例：单位注册码框为空时，会提示：请输入单位注册码
    @data(*ZHUCEData1().data11())
    @unpack
    def testassessment218(self,expect):
        # # 创建浏览器对象
        driver = webdriver.Chrome()
        # 执行登陆并新增考核表等操作
        log = TestUntitled1()
        log.test_untitled_c(driver)
        # 获取实际结果并断言
        result = log.test_untitled6(driver)
        if result != expect:
            driver.save_screenshot("218bug.jpg")
        driver.quit()
        self.assertEqual(expect, result)

#221用例：点击个人注册，输入错误的单位注册码，提示：单位不存在
    @data(*ZHUCEData1().data12())
    @unpack
    def testassessment221(self, name,expect):
        # # 创建浏览器对象
        driver = webdriver.Chrome()
        # 执行登陆并新增考核表等操作
        log = TestUntitled1()
        log.test_untitled_c(driver)
        # 获取实际结果并断言
        result = log.test_untitled7(driver, name)
        if result != expect:
            driver.save_screenshot("221bug.jpg")
        driver.quit()
        self.assertEqual(expect, result)

#222用例：点击个人注册，输入存在的单位注册码，会跳转到二级域名：http://12.hjypt.com/account/register?web=1
    @data(*ZHUCEData1().data13())
    @unpack
    def testassessment222(self, name,expect):
        # # 创建浏览器对象
        driver = webdriver.Chrome()
        # 执行登陆并新增考核表等操作
        log = TestUntitled1()
        log.test_untitled_c(driver)
        # 获取实际结果并断言
        result = log.test_untitled8(driver, name)
        if result != expect:
            driver.save_screenshot("222bug.jpg")
        driver.quit()
        self.assertEqual(expect, result)

#223用例：点击个人注册，输入中文，进行注册会提示：请输入字母或数字
    @data(*ZHUCEData1().data14())
    @unpack
    def testassessment223(self,name,expect):
        # # 创建浏览器对象
        driver = webdriver.Chrome()
        # 执行登陆并新增考核表等操作
        log = TestUntitled1()
        log.test_untitled_c(driver)
        # 获取实际结果并断言
        result = log.test_untitled7(driver, name)
        if result != expect:
            driver.save_screenshot("223bug.jpg")
        driver.quit()
        self.assertEqual(expect, result)